package cn.iocoder.yudao.module.member.dal.mysql.newsStudyInfo;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.newsStudyInfo.NewsStudyInfoDO;
import cn.iocoder.yudao.module.member.dal.dataobject.newsStudyType.NewsStudyTypeDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.newsStudyInfo.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 新闻信息(成果信息) Mapper
 *
 * @author 管理员
 */
@Mapper
public interface NewsStudyInfoMapper extends BaseMapperX<NewsStudyInfoDO> {

    default PageResult<NewsStudyInfoDO> selectPage(NewsStudyInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NewsStudyInfoDO>()
                .eqIfPresent(NewsStudyInfoDO::getTitle, reqVO.getTitle())
                .eqIfPresent(NewsStudyInfoDO::getType, reqVO.getType())
                .eqIfPresent(NewsStudyInfoDO::getTypeId, reqVO.getTypeId())
                .eqIfPresent(NewsStudyInfoDO::getHeadUrl, reqVO.getHeadUrl())
                .eqIfPresent(NewsStudyInfoDO::getAppletUrl, reqVO.getAppletUrl())
                .eqIfPresent(NewsStudyInfoDO::getDetail, reqVO.getDetail())
                .eqIfPresent(NewsStudyInfoDO::getPdfUrl, reqVO.getPdfUrl())
                .eqIfPresent(NewsStudyInfoDO::getVideoUrl, reqVO.getVideoUrl())
                .betweenIfPresent(NewsStudyInfoDO::getReleaseTime, reqVO.getBeginReleaseTime(), reqVO.getEndReleaseTime())
                .eqIfPresent(NewsStudyInfoDO::getStatus, reqVO.getStatus())
                .eqIfPresent(NewsStudyInfoDO::getWeight, reqVO.getWeight())
                .betweenIfPresent(NewsStudyInfoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(NewsStudyInfoDO::getId));
    }

    default List<NewsStudyInfoDO> selectList(NewsStudyInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<NewsStudyInfoDO>()
                .eqIfPresent(NewsStudyInfoDO::getTitle, reqVO.getTitle())
                .eqIfPresent(NewsStudyInfoDO::getType, reqVO.getType())
                .eqIfPresent(NewsStudyInfoDO::getTypeId, reqVO.getTypeId())
                .eqIfPresent(NewsStudyInfoDO::getHeadUrl, reqVO.getHeadUrl())
                .eqIfPresent(NewsStudyInfoDO::getAppletUrl, reqVO.getAppletUrl())
                .eqIfPresent(NewsStudyInfoDO::getDetail, reqVO.getDetail())
                .eqIfPresent(NewsStudyInfoDO::getPdfUrl, reqVO.getPdfUrl())
                .eqIfPresent(NewsStudyInfoDO::getVideoUrl, reqVO.getVideoUrl())
                .betweenIfPresent(NewsStudyInfoDO::getReleaseTime, reqVO.getBeginReleaseTime(), reqVO.getEndReleaseTime())
                .eqIfPresent(NewsStudyInfoDO::getStatus, reqVO.getStatus())
                .eqIfPresent(NewsStudyInfoDO::getWeight, reqVO.getWeight())
                .betweenIfPresent(NewsStudyInfoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(NewsStudyInfoDO::getId));
    }

    long getTotalByIds(@Param("ids") List<Long> ids);

    void updateNewsStudyInfo(@Param("status") String status
            ,@Param("typeId") Long typeId
            ,@Param("deleted") Boolean deleted
            ,@Param("ids") List<Long> ids);


    Integer getNewsStudyWeight(Integer type);

    List<NewsStudyInfoDO> getNewsStudyInfoList(IPage page, @Param("params") Map<String, Object> params);

    NewsStudyInfoDO getNewsStudyInfoById(@Param("id") Long id);

    void updateViewNum(@Param("id") Long id);

    void updateByStudyTypeId(@Param("typeId") Long typeId);
}
